home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cwl2f-3.zip / UPDATE.DOC < prev   
Text File  |  1992-06-10  |  7KB  |  177 lines

  1.    Here are the last minute changes to The C Window Library manual:
  2.  
  3.  
  4.   Important Information for C++ users
  5.   -----------------------------------
  6.  
  7.   If you are using the Zortech C++ or Borland C++ compilers, and you are using
  8.   the C++ compile option,  here are some things to look out for:
  9.  
  10.   -  Declare any user-defined menu functions as functions with variable
  11.      arguments.  If you have included window.h in your source file, you can
  12.      use the UNKNOWNARGS macro.  Here is an example:
  13.  
  14.  
  15.      int menu_func(UNKNOWNARGS);
  16.  
  17.      BAR_MENU_ENTRY bar_items[] = {
  18.                                     "File",1,4,'F',ALTF,menu_func,
  19.                                     "Edit",1,10,'E',0,menu_func,
  20.  
  21.                                     /* Rest of definitions */
  22.  
  23.  
  24.      or if you are creating menus dynamically:
  25.  
  26.  
  27.     BarCreateEntry(menu_array,1,"File",1,4,'F',ALTF,menu_func);
  28.  
  29.  
  30.     The same thing applies to popup menus.
  31.  
  32.  
  33.   - The function body of the user defined menu functions MUST be located in a
  34.     different source file than the file where they were defined.
  35.  
  36.     For example, FILE1.CPP contains the following:
  37.  
  38.      int menu_func(UNKNOWNARGS);
  39.  
  40.      BAR_MENU_ENTRY bar_items[] = {
  41.                                     "File",1,4,'F',ALTF,menu_func,
  42.                                     "Edit",1,10,'E',0,menu_func,
  43.  
  44.                                     /* Rest of definitions */
  45.  
  46.  
  47.  
  48.    Then you must have a file, say FILE2.CPP, with the following:
  49.  
  50.    int menu_func(BAR_MENU_PTR, int);
  51.  
  52.  
  53.    int menu_func(BAR_MENU_PTR b, int sel)
  54.    {
  55.       /* Function body */
  56.    }
  57.  
  58.  
  59.    The reasons for this is that the definition for the user defined menu
  60.    function is a pointer to a function with an unknown number of arguments.
  61.    Therefore, C++ users must declare their user function as such or an error
  62.    will occur during compilation.  To fool the compiler, we have declared all
  63.    of the user-defined menu functions as functions with an unknown number of
  64.    arguments in FILE1.CPP, and the body of the function is located in
  65.    FILE2.CPP with the passed arguments from the menu manager.
  66.  
  67.    So far this method works with the TLINK linker for Turbo (Borland) C++, and
  68.    BLINK for the Zortech compiler.  This method may not work with other linkers
  69.    out there that may do extensive type checking.
  70.  
  71.    I will probably make changes in future versions to alleviate this problem
  72.    for C++ users.
  73.  
  74.            CLICKING OR RELEASING THE MOUSE OUTSIDE OF A MENU
  75.            -------------------------------------------------
  76.  
  77.    You can now define a function to perform when the mouse is clicked 
  78.    or released outside of a popup, bar, or pulldown.  The menu 
  79.    must be created with the BARSETMOUSE or POPUPSETMOUSE menu options 
  80.    for bar and popup menus, respectively.  
  81.  
  82.    Previously, when the mouse was clicked or released outside a menu 
  83.    window, nothing occurred.  There are quite a few menuing systems 
  84.    where a mouse click outside a menu closes the menu.  To make this 
  85.    option as flexible as possible, a user defined function can be 
  86.    called when a mouse click is detected outside a menu.
  87.  
  88.    The BarSetClickFunction() and the PopupSetClickFunction() define 
  89.    functions to be called when a mouse click or release is detected 
  90.    outside a menu window.
  91.  
  92.    The prototype for these two functions is as follows:
  93.  
  94.       int BarSetClickFunction(BAR_MENU_PTR bar, 
  95.                               int (*func)(BAR_MENU_PTR b, int row, 
  96.                                           int col, int selection))
  97.  
  98.       int PopupSetClickFunction(POPUP_MENU_PTR popup, 
  99.                                 int (*func)(POPUP_MENU_PTR p, 
  100.                                             int row, int col, 
  101.                                             int selection))
  102.  
  103.    The first argument is the menu pointer to assign the function to.  
  104.    The second argument is the pointer to the function that will be 
  105.    called when a mouse click (or release) is detected outside the menu 
  106.    window.
  107.  
  108.    The first argument passed to the user-defined function is the menu 
  109.    pointer.  The second and third arguments are the row and column of 
  110.    the mouse when it was pressed.  The row and column are in absolute 
  111.    screen coordinates, not mouse or window coordinates.  The last 
  112.    argument is the mouse button that was pressed.  The value of this 
  113.    constant is either MOUSELEFT_PRESS, MOUSERIGHT_PRESS or 
  114.    MOUSEMIDDLE_PRESS depending on the button that was pressed or 
  115.    released.  
  116.  
  117.    The user defined function MUST return a value back to the menu 
  118.    manager.  These return values are the same as the return values for 
  119.    the menu undefined key functions (popup_undef_key or bar_undef_key).  
  120.    Refer to the PROCESSING UNDEFINED KEYS section of the menu chapter 
  121.    in the documentation for these return values.
  122.  
  123.    For pulldown menus, you should call PopupSetClickFunction() for each 
  124.    popup menu of the pulldown system.  You should also use the same 
  125.    function to call for each popup.  You should also call 
  126.    BarSetClickFunction() so that the pulldown menu can act on clicks 
  127.    when the pulldown menu is currently at the bar menu level.  
  128.  
  129.    If you want to turn off the click function, use the 
  130.    NO_BAR_CLICK_FUNC or NO_POPUP_CLICK_FUNC macro as the second 
  131.    argument to PopupSetClickFunction() or BarSetClickFunction(), 
  132.    respectively.
  133.  
  134.    Example:   BarSetClickFunction(bar,NO_BAR_CLICK_FUNC)
  135.  
  136.    The return values of BarSetClickFunction() are the same as 
  137.    BarSetMouse().  The return values of PopupSetClickFunction() are the 
  138.    same as PopupSetMouse(). 
  139.  
  140.  
  141.    Example:
  142.  
  143.        #include "cwlmouse.h"
  144.        #include "menu.h"
  145.        int popup_click_func(POPUP_MENU_PTR, int, int, int);
  146.        POPUP_MENU_PTR p;
  147.  
  148.  
  149.        main()
  150.        {
  151.          ...
  152.          MouseInitializeSystem(/* arguments */);
  153.          p = PopupCreateMenu(/* create menu arguments */);
  154.          PopupSetOptions(p,POPUPMOUSE);
  155.          PopupSetClickFunction(p,popup_click_func);
  156.  
  157.          ...
  158.        }
  159.  
  160.  
  161.        int popup_click_function(POPUP_MENU_PTR pop, int row, int col,
  162.                                 int sel)
  163.  
  164.        {
  165.          /* quit menu if mouse clicked ouside of menu */
  166.          return POPUP_ESCAPE;
  167.        }
  168.  
  169.  
  170.    The above example exits the popup menu when the mouse is clicked or 
  171.    released outside of the menu window.  If this were a pulldown menu 
  172.    the return value to exit the pulldown menu would have been 
  173.    POPUP_PULLDOWN_EXIT.
  174.  
  175.  
  176.  
  177.